package com.pda.gongpin.ui.fulltrayin;

import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.pda.gongpin.R;
import com.pda.gongpin.adapter.FullTrayInDetailAdapter;
import com.pda.gongpin.bean.FullTrayInDetailBean;
import com.pda.gongpin.bean.request.EntryNoRequest;
import com.pda.gongpin.contract.FullTrayInDetailContract;
import com.pda.gongpin.presenter.FullTrayInDetailPresenter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.wangshen.base.ui.mvp.base.ui.BaseMvpFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

;

public class FullTrayInDetailFragment extends BaseMvpFragment<FullTrayInDetailPresenter> implements FullTrayInDetailContract.View, OnRefreshListener {

    @BindView(R.id.rv_content)
    RecyclerView rvContent;
    @BindView(R.id.tv_deliveryNo)
    TextView tvDeliveryNo;
    @BindView(R.id.smart)
    SmartRefreshLayout smart;
    private String entryNo,erpCode;
    FullTrayInDetailAdapter fullTrayInDetailAdapter;

    public FullTrayInDetailFragment(String entryNo, String erpCode) {
        this.entryNo = entryNo;
        this.erpCode = erpCode;
    }

    public FullTrayInDetailFragment(String entryNo) {
        this.entryNo = entryNo;
    }

    public FullTrayInDetailFragment() {
    }

    @Override
    public FullTrayInDetailPresenter getPresenter() {
        return new FullTrayInDetailPresenter();
    }

    @Override
    public int getViewId() {
        return R.layout.fragment_detail;
    }

    @Override
    public void initView() {
        smart.setEnableLoadMore(false);
        smart.setOnRefreshListener(this);
        tvDeliveryNo.setText("入库单信息 " + erpCode);
        fullTrayInDetailAdapter = new FullTrayInDetailAdapter(R.layout.item_full_in_detail, new ArrayList<>());
        fullTrayInDetailAdapter.setPresenter(presenter);
        rvContent.setAdapter(fullTrayInDetailAdapter);
        smart.autoRefresh();
    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {

    }

    @Override
    public void showMessage(String msg) {
        super.showMessage(msg);
        smart.finishRefresh();
    }

    @Override
    public void setList(List<FullTrayInDetailBean> list) {
        fullTrayInDetailAdapter.setNewInstance(list);
        smart.finishRefresh();
    }

    @Override
    public void onSuccess() {
        smart.autoRefresh();
    }

    @Override
    public void onRefresh(RefreshLayout refreshLayout) {
        presenter.palletEntryDetail(entryNo);
    }
}
